package com.zhouyibike.uu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhouyibike.uu.R;
import com.zhouyibike.uu.entity.LvMenuItem;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by Administrator on 2017/4/22 0022.
 */
public class LeftItemAdapter extends BaseAdapter {
    private Context mContext;

    public LeftItemAdapter(Context mContext) {
        this.mContext = mContext;
    }

    private List<LvMenuItem> mItems = new ArrayList<LvMenuItem>(
            Arrays.asList(
//                    new LvMenuItem(R.drawable.xingcheng_left, "我的行程"),
//                    new LvMenuItem(R.drawable.qianbao_left, "我的钱包"),
//                    new LvMenuItem(R.drawable.danche_left, "我的单车"),
//                    new LvMenuItem(R.drawable.yaoqing_left, "邀请分享"),
//                    new LvMenuItem(R.drawable.paiming_left, "骑车排名")

                    new LvMenuItem(R.mipmap.left_qianbao, "我的钱包"),
                    new LvMenuItem(R.mipmap.left_bike, "我的单车"),
                    new LvMenuItem(R.mipmap.left_yaoqing,"邀请分享"),
                    new LvMenuItem(R.mipmap.left_xingcheng,"我的行程")
                    , new LvMenuItem(R.mipmap.left_yhd,"翼活动"),
                    new LvMenuItem(R.mipmap.left_dchhr, "单车合伙人")
                    , new LvMenuItem(R.mipmap.left_chhhr,"城市合伙人")

            ));


    @Override
    public int getCount() {
        return mItems.size();
    }


    @Override
    public Object getItem(int position) {
        return mItems.get(position);
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.adapter_left_item, null);
        TextView tv_state = (TextView) convertView.findViewById(R.id.tv_left_state);
        ImageView iv_pic = (ImageView) convertView.findViewById(R.id.iv_left_img);
        TextView tv_name = (TextView) convertView.findViewById(R.id.tv_left_name);

//        convertView.setY((float) (DataSingle.getInstance().PhoneH * 0.04));
        if (position == 1) {
//             if (((MainActivity)mContext).has20)
            if (true) {
                tv_state.setVisibility(View.VISIBLE);
            } else {
                tv_state.setVisibility(View.GONE);
            }
        } else {
            tv_state.setVisibility(View.GONE);
        }
        tv_state.setText("认购单车");
        iv_pic.setImageResource(mItems.get(position).getIcon());
        tv_name.setText(mItems.get(position).getName());
        return convertView;
    }
}
